<template>
	<view>
		<view class="my_herder">
			<view class="p-q5 f qiandao">
				<view class="my_h_l">
					<view class="my_h_ltx"><image :src="imgstou" mode="widthFix"></image></view>
					<view class="my_h_lsj m-l4">
						<text class="m-t3">签到得积分</text>
						<text class="m-t2">签到{{qd_as}}天</text>
					</view>
				</view>
				<view class="my_h_r m-t3" @click="open_init()">
					<i class="iconfont icon-jifen m-l2"></i>
					<text class="m-l1 m-r2">签到</text>
				</view>
			</view>
		</view>
		<!--  -->
		<view class="qiandao_s">
			<view class=" w-yb qd_t p-l4 w-l8" style="display: none;">
				签到得积分
			</view>
			<view class="qiandao_lis m-q2">
				<!-- <view class="qiandao_lit active" v-for="(item,index) in cons" :key='index' >
					<text>{{item}}</text>
				</view> -->
				<uni-calendar :date="shiji" :selected="selected" @change="change"></uni-calendar>
			</view>
			<!-- 弹出框 -->
			<uni-popup class="popss" ref="popup">
				
				<view class="popup-content">
					<view class="posi">
						<view class="qd_lx">
							<text>{{qd}}</text>
						</view>
						<button class="zhidao" type="warn" @tap="close()">知道了</button>
					</view>
				</view>
			</uni-popup>
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				type:1,
				cons:[],
				imgstou:'',
				qd_as:[],
				shiji:'',
				qd:'',
				selected:[],
				iconClassList: 'arrowright',
			}
		},
		onLoad(option){
			// this.imgstou = option.id
			// console.log(this.id)
		},
		created() {
		},
		onShow() {
			this.shiji = new Date().toISOString().slice(0, 10);
			console.log(this.shiji)
			this.open_signin()
		},
        onNavigationBarButtonTap(e){
			if(e.index ==0){
				uni.navigateTo({
					url:'./shezhi'
				})
			}
        },
		methods:{
			change(e){
				console.log(e)
			},
			open_init(index){
				var that = this;
				that.type = index;
				that.$refs.popup.open('center')
				that.pyReq(that.$http.signin,{},function(res){
						  that.$refs.popup.open('center')
						  that.qd = res.msg
						  that.selected = []
						  that.open_signin()
				});
				// let headers={
				// 	  'content-type': 'application/x-www-form-urlencoded',
				// 	  'token': uni.getStorageSync('token')
				// }
				//  uni.request({
				// 	  url: that.$http.signin,
				// 	  method: 'POST',
				// 	  header:headers,
				// 	  success: (res)=>{
				// 		  console.log(res)
				// 		  this.$refs.popup.open('center')
				// 		  that.qd = res.data.msg
				// 		  that.selected = []
				// 		  that.open_signin()
				// 	  },
				// 	  fail: (err)=>{
				// 		  console.log(err)
				// 	  }
				// })  
			},
			open_signin(){
				let that = this
				that.pyReq(that.$http.getSigninDetail,{},function(res){
						  for(let i in res.result.signined){
							  var j = {}
							  j.date = res.result.signined[i]
							  that.selected.push(j)
						  }
						  
						  that.qd_as = res.result.signined.length
				});
				// let headers={
				// 	  'content-type': 'application/x-www-form-urlencoded',
				// 	  'token': uni.getStorageSync('token')
				// }
				//  uni.request({
				// 	  url: that.$http.getSigninDetail,
				// 	  method: 'POST',
				// 	  header:headers,
				// 	  success: (res)=>{
				// 		  console.log(res)
				// 		  // that.cons = res.data.result.signined
				// 		  for(let i in res.data.result.signined){
				// 			  var j = {}
				// 			  j.date = res.data.result.signined[i]
				// 			  that.selected.push(j)
				// 		  }
						  
				// 		  that.qd_as = res.data.result.signined.length
				// 		  console.log(that.qd_as)
				// 	  },
				// 	  fail: (err)=>{
				// 		  console.log(err)
				// 	  }
				// }) 
				 that.pyReq(that.$http.getMyInfo,{},function(res){
					
				 });
				 // uni.request({
				 // 	url: that.$http.getMyInfo,
				 // 	method: 'POST',
				 // 	header: headers,
				 // 	success: (res) => {
				 // 		console.log(res)
				 // 		if(res.data.code == '1001'){
				 // 		  uni.showModal({
				 // 		      title: '提示',
				 // 		      content: res.data.msg,
				 // 		      success: function (res) {
				 // 		          if (res.confirm) {
				 // 		             uni.reLaunch({
				 // 		             	url:'/pages/index/logo/logo'
				 // 		             })
				 // 		          } else if (res.cancel) {
				 // 		              console.log('用户点击取消');
				 // 		          }
				 // 		      }
				 // 		  });
				 // 		}else{
				 // 			that.imgstou = res.data.result.avatar
				 // 		}
				 // 		uni.hideLoading();
				 // 	},
				 // 	fail: (err) => {
				 // 		console.log(err)
				 // 	}
				 // })
			},
			dataAction:function(){
				this.$refs.mainindex.getLocationInfo();
			},
			close(){
				this.$refs.popup.close()
			}
		}
	}
				
</script>

<style>
	.zhidao{
		font-size: 28upx;
		margin-top: 50upx;
		line-height: 88upx;
	}
	.qd_lx{
		width: 320upx;
		height: 48upx;
		background-color: #FF9103;
		color: #FFFFFF;
		text-align: center;
		margin: 0 auto;
		margin-top: 443upx;
		border-radius: 30upx;
	}
	.posi{
		width: 495upx;
		height: 625upx;
		background: #FFFFFF;
		border-radius: 20upx;
		overflow: hidden;
		background-image: url(../../static/qdbj.png);
		background-position: center;
		background-size: 100% 100%;
	}
	.qiandao_lit{
		display: flex;
		flex-direction: column;
		align-items: center;
		border: 1upx solid #8f8f8f;
		color: #8f8f8f;
		border-radius: 20upx;
		width: 175upx;
		padding: 40upx 0;
		margin: 27upx;
	}
	.qiandao_lis{
		display: flex;
		/* justify-content: space-around; */
		flex-wrap: wrap;
		margin-bottom: 50upx;
	}
	.qd_t{
		font-size: 30upx;
		font-weight: 700;
		height: 90upx;
		background-color: #B31610;
	}
	.qiandao_s{
		width: 750upx;
		/* border: 1upx solid #B31610; */
		margin: 0 auto;
		/* margin-top: 48upx; */
		border-radius: 20upx;
		overflow: hidden;
	}
	.qiandao{
		justify-content: space-between;
	}
	.my_h_r{
		color: #B31610;
		border-radius: 50upx;
		font-size: 26upx;
		height:60upx;
		padding: 0 20upx;
		border: 1upx solid #FFFFFF;
		text-align: center;
	}
	.my_h_r text{
		color: #FFFFFF;
	}
	.my_h_r .icon-jifen{
		color: #FFFFFF;
	}
	.my_herder{
		background-color: #B31610;
		padding-bottom: 20upx;
	}
	.my_h_l{
		display: flex;
	}
	.my_h_ltx{
		float: left;
		width: 130upx;
		height: 130upx;
		border-radius: 50%;
		overflow: hidden;
	}
	.my_h_ltx image{
		width: 100%;
	}
	.my_h_lsj{
		float: left;
	}
	.my_h_lsj text{
		display: block;
		color: #FFFFFF;
	}
	.active{
		color: #B31610;
		border: 1px solid #B31610;
	}
</style>
